package com.zt.springcloud.controller;

import com.zt.springcloud.entity.vo.OrderListVo;
import com.zt.springcloud.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author RedReins
 * @version 1.0
 * @description: TODO
 * @date 2021/9/11 18:35
 */

@RestController
public class OrderController {
    @Resource
    private OrderService orderService;
    @RequestMapping(value = "/createOrder",method = RequestMethod.POST)
    public Boolean createOrder(@RequestBody String reqData,@RequestParam("userId") Long userId) {
        return orderService.createOrder(reqData,userId);
    }
    /*
    * 查询用户所有订单
    * */
    @RequestMapping(value = "/orderList",method = RequestMethod.POST)
    public List<OrderListVo> getUserAllOrder(@RequestParam("userId") Long userId){
        return orderService.getUserAllOrder(userId);
    }
    /*
    * 删除订单中的商品
    * */
    @RequestMapping(value = "/orderDelete/{orderId}",method = RequestMethod.DELETE)
    public Boolean deleteOrderItem(@PathVariable("orderId") String orderId){
        return orderService.deleteOrderItem(orderId);
    }
}
